package com.cysyz.web.modules.base.permission.domain;


import com.cysyz.mylib.domain.CreateTimeRegisterEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * SysRole entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "FNM_SYS_ROLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SysRole extends CreateTimeRegisterEntity {

	// Fields
	@Column(name = "NAME", nullable = false, length = 20, unique = true)
	private String name;
	@Column(name = "CODE", nullable = false, length = 20, unique = true)
	private String code;

	@Transient
	private Boolean isdefault = false;

	@Column(name = "DESCRIPTION", length = 100)
	private String description;
	@Column(name = "PRIVILEGES", length = 20000)
	private String privileges;
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysRole")
	private Set<SysSysrolePrivilege> sysSysrolePrivileges = new HashSet<SysSysrolePrivilege>(0);
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysRole")
	private Set<SysUserRole> sysUserRoles = new HashSet<SysUserRole>(0);

	@Override
	public String[] businessKeys() {
		return new String[]{"code"};
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Transient
	public Boolean getIsdefault() {
		return isdefault;
	}

	public void setIsdefault(Boolean isdefault) {
		this.isdefault = isdefault;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getPrivileges() {
		return privileges;
	}

	public void setPrivileges(String privileges) {
		this.privileges = privileges;
	}

	public Set<SysSysrolePrivilege> getSysSysrolePrivileges() {
		return sysSysrolePrivileges;
	}

	public void setSysSysrolePrivileges(Set<SysSysrolePrivilege> sysSysrolePrivileges) {
		this.sysSysrolePrivileges = sysSysrolePrivileges;
	}

	public Set<SysUserRole> getSysUserRoles() {
		return sysUserRoles;
	}

	public void setSysUserRoles(Set<SysUserRole> sysUserRoles) {
		this.sysUserRoles = sysUserRoles;
	}

}